package com.etoak.controller;

import com.etoak.config.TopicConfig;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/topic")
public class TopicController {
    @Autowired
    RabbitTemplate rabbitTemplate;

    @RequestMapping("/send")
    public String send() {
        rabbitTemplate.convertAndSend(TopicConfig.EXCHANGE, "an.orange.juice", "一杯橙汁");
        rabbitTemplate.convertAndSend(TopicConfig.EXCHANGE, "big.white.rabbit", "大白兔");
        rabbitTemplate.convertAndSend(TopicConfig.EXCHANGE, "an.orange.rabbit", "一只橙色兔子");
        rabbitTemplate.convertAndSend(TopicConfig.EXCHANGE, "lazy.rabbit", "懒兔子");
        return "success";
    }
}
